package com.slkj.shilixiaoyuanapp.ui.teacher.tool.MaterialAudit;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.example.api.InjectParam;
import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.slkj.shilixiaoyuanapp.R;
import com.slkj.shilixiaoyuanapp.base.ActivityInfo;
import com.slkj.shilixiaoyuanapp.base.BaseActivity;
import com.slkj.shilixiaoyuanapp.base.LazyFragmentPagerAdapter;
import com.slkj.shilixiaoyuanapp.ui.teacher.tool.common.CommonToolHistoryActivity__JumpCenter;
import com.slkj.shilixiaoyuanapp.ui.teacher.tool.common.CommonToolHistoryFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindArray;
import butterknife.BindView;

/**
 * 材料审核历史记录
 */
@ActivityInfo(layout = R.layout.activity_common_tool_history,title = "审核")
public class MaterialAuditHistoryActivity extends BaseActivity {
    /**
     * 工具类型
     */
    @InjectParam int toolType;
    @InjectParam int netToolType;
    @BindArray(R.array.meeting_his_tab)
    String[] titles;
    @BindView(R.id.tab_layout)
    SlidingTabLayout tablayout;
    @BindView(R.id.viewpager)
    ViewPager viewpager;
    LazyFragmentPagerAdapter fragmentPagerAdapter;
    private List<MaterialAuditHistoryFragment> fragments = new ArrayList<>();
    private int current = 0;
    @Override
    protected void init() {
        MaterialAuditHistoryActivity__JumpCenter.bind(this);
        fragments.add(MaterialAuditHistoryFragment.get(MaterialAuditHistoryFragment.TYPE_ALL));
        fragments.add(MaterialAuditHistoryFragment.get(MaterialAuditHistoryFragment.TYPE_NOT_LOOK));
        fragments.add(MaterialAuditHistoryFragment.get(MaterialAuditHistoryFragment.TYPE_REFUSE));
        fragments.add(MaterialAuditHistoryFragment.get(MaterialAuditHistoryFragment.TYPE_OK));
        fragmentPagerAdapter = new LazyFragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return fragments.get(position);
            }

            @Override
            public int getCount() {
                return fragments.size();
            }

            @Nullable
            @Override
            public CharSequence getPageTitle(int position) {
                return titles[position];
            }
        };
        viewpager.setAdapter(fragmentPagerAdapter);
        tablayout.setViewPager(viewpager);
        tablayout.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
                current = position;

            }

            @Override
            public void onTabReselect(int position) {

            }
        });

    }

    @Override
    protected void onRightTitleClick() {
        fragments.get(current).setInSeleteStatu();
    }
}
